package com.qiedan.controller.mdy;


import com.qiedan.bean.User;
import com.qiedan.service.UserService;
import com.qiedan.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RequestMapping("/user")
@RestController
@Slf4j
public class MUserController {

    @Autowired
    UserService userService;

    @RequestMapping(value = "/register", method = RequestMethod.POST)
    public R<Object> register(@RequestBody User user){
        log.info("user:"+user.toString());

        R<Object> resp  = userService.register(user);

        return resp;
    }

    /**
     * 用户登陆...
     * @param user
     * @return
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public R<Object> login( @RequestBody User user){
        log.info("user:"+user.toString());
        return userService.login(user);
    }

    /**
     * 重置密码...
     * @param user
     * @return
     */
    @RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
    public R<Object> updatePassword( @RequestBody User user){
        log.info("user:"+user.toString());
        return userService.updatePassword(user);
    }
    /**
     * 重置用户信息...
     * @param user
     * @return
     */
    @RequestMapping(value = "/updateUserInfo", method = RequestMethod.POST)
    public R<Object> updateUserInfo( @RequestBody User user){
        log.info("user:"+user.toString());
        return userService.updateUserInfo(user);
    }
}
